﻿using B.S.BasicData.ErrorCode;
using B.S.BasicData.Write.Application.Common.Menu;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class MenuController : ControllerBase
    {
        private readonly IMediator mediator;

        public MenuController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 菜单新增
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateMenuHandle(CreateMenuCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 菜单修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateMenuHandle(UpdateMenuCommon request)
        {
            return mediator.Send(request);
        }
        ///// <summary>
        ///// 菜单逻辑删除
        ///// </summary>
        ///// <param name="request"></param>
        ///// <returns></returns>
        //[HttpPut]
        //public Task<ApiResult<int>> DelMenuHandle(DelMenuCommon request)
        //{
        //    return mediator.Send(request);
        //}
        /// <summary>
        /// 逻辑删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelMenuHandle(DelMenuCommon request)
        {
            return await mediator.Send(request);
        }

        }
}
